package com.city.parking.map;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.MapStatusUpdateFactory;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.model.LatLng;
import com.city.parking.R;

public class BaseMapActivity extends Activity {
	final static String TAG = "BaseMapActivity";
	private MapView mMapView = null;
	private BaiduMap mBaiduMap;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_basemap);
		mMapView = (MapView) findViewById(R.id.bmapView);

		LatLng p;
		double dLat = 38.945;
		double dLon = 119.404;
		Intent intent = getIntent();
		if (intent.hasExtra("x") && intent.hasExtra("y")) {
			Bundle b = intent.getExtras();
			p = new LatLng(b.getDouble("y"), b.getDouble("x"));
		} else {
			p = new LatLng(dLat, dLon);
		}

		mBaiduMap = mMapView.getMap();

		mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng(p));
	}

	@Override
	protected void onPause() {
		super.onPause();
		mMapView.onPause();
	}

	@Override
	protected void onResume() {
		super.onResume();
		mMapView.onResume();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		mMapView.onDestroy();
	}
}
